﻿using System;
using System.Collections.Generic;
using System.Text;

namespace TSVNAddin.Core
{
	public class ActiveCommandContext : IPathCommandContext
	{
		private readonly ActiveDocumentAdapter _ActiveDocument;
		private readonly WorkingContext _WorkingContext;

		public ActiveCommandContext(ActiveDocumentAdapter activeDocument, WorkingContext workingContext)
		{
			_ActiveDocument = activeDocument;
			_WorkingContext = workingContext;
		}

		public CommandStatus GetCommandStatus()
		{
			if (!_ActiveDocument.IsVersionable())
				return CommandStatus.Disabled;

			if (!_WorkingContext.CanExecuteCommandsOnPath(_ActiveDocument.GetFileName()))
				return CommandStatus.Disabled;

			return CommandStatus.Enabled;
		}

		public string GetWorkingPath()
		{
			return _ActiveDocument.GetFileName();
		}
	}
}
